package com.allwees.bs;

import com.allwees.core.cache.annotation.EnableCache;
import com.allwees.core.mq.rabbitmq.annotation.EnableMq;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Date;

/**
 * @author jie
 * @date 2018/11/15 9:20:19
 */
@SpringBootApplication(exclude = RestClientAutoConfiguration.class)
@EnableConfigurationProperties
@EnableTransactionManagement
@EnableAsync
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@ComponentScan(basePackages = {"com.allwees", "me.zhengjie"})
@EntityScan(basePackages = {"com.allwees", "me.zhengjie"})
@EnableJpaRepositories(basePackages = {"com.allwees", "me.zhengjie"})
@MapperScan({"com.allwees.bs.**.dao","com.allwees.support.**.dao"})
@EnableCache
@EnableMq
@Slf4j
public class BusinessServerApplication {
	public static void main(String[] args) {
		log.info(">>>>>>>>>>>>>>>>>>>> current time:{} <<<<<<<<<<<<<<<<<<<<", new Date());
		SpringApplication.run(BusinessServerApplication.class, args);
	}

//	@Bean
//	public SpringContextHolder springContextHolder() {
//		return new SpringContextHolder();
//	}

	@Bean
	public ServletWebServerFactory webServerFactory() {
		TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory();
		fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
		return fa;
	}
}
